package com.anolesoft.yr.mbus.prod.pack.mapper;

import com.anolesoft.yr.mbus.prod.pack.dto.ProdPackageDeleteDTO;
import com.anolesoft.yr.mbus.prod.pack.dto.ProdPackageSaveDTO;
import com.anolesoft.yr.mbus.prod.pack.dto.ProdPackageUpdateDTO;
import com.anolesoft.yr.mbus.prod.pack.entity.ProdPackage;
import com.anolesoft.yr.mbus.prod.pack.entity.ProdPackageService_;
import com.anolesoft.yr.mbus.prod.pack.sql.ProdPackageSQL;
import com.anolesoft.yr.mbus.prod.pack.vo.ProdPackageQueryVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProdPackageMapper {

    //新增时查询产品套餐编号是否已经存在
    @Select(ProdPackageSQL.QUERY_PROD_PACKAGE_BY_CODE)
    @Results(id = "queryProdPackageByCode", value = {
            @Result(column = "count", property = "count")
    })
    int queryProdPackageByCode(String value);

    //新增时查询产品套餐名称是否已经存在
    @Select(ProdPackageSQL.QUERY_PROD_PACKAGE_BY_NAME)
    @Results(id = "queryProdPackageByName", value = {
            @Result(column = "count", property = "count")
    })
    int queryProdPackageByName(String name);

    //根据主键查询产品套餐唯一数据
    @Select(ProdPackageSQL.QUERY_PROD_PACKAGE_VERSION_BY_UID)
    @Results(id = "queryProdPackageVersionByUid", value = {
            @Result(column = "version", property = "version")
    })
    ProdPackageQueryVO queryProdPackageVersionByUid(@Param("prodProductionUid") String prodProductionUid, @Param("speciesName") String speciesName);

    //新增产品套餐信息表
    @Insert(ProdPackageSQL.SAVE_PROD_PACKAGE)
    int saveProdPackage(ProdPackageSaveDTO prodPackageSaveDTO);

    //根据主键查询产品套餐唯一数据
    @Select(ProdPackageSQL.QUERY_PROD_PACKAGE_BY_UID2)
    @Results(id = "queryProdPackageByUid2", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "fac_code", property = "facCode"),
            @Result(column = "prod_production_uid", property = "prodProductionUid"),
            @Result(column = "species_code", property = "speciesCode"),
            @Result(column = "species_name", property = "speciesName"),
            @Result(column = "species_describe", property = "speciesDescribe"),
            @Result(column = "species_approval_state", property = "speciesApprovalState"),
            @Result(column = "is_setup", property = "isSetup"),
            @Result(column = "start_time", property = "startTime"),
            @Result(column = "invalid_time", property = "invalidTime"),
            @Result(column = "version", property = "version"),
            @Result(column = "remark", property = "remark"),
            @Result(column = "c_user_uid", property = "ccUserUid"),
            @Result(column = "c_time", property = "ccTime"),
            @Result(column = "m_user_uid", property = "mmUserUid"),
            @Result(column = "m_time", property = "mmTime"),
            @Result(column = "del_flag", property = "delFlag")
    })
    ProdPackage queryProdPackageByUid2(String uid);

    //根据主键查询当前产品套餐最高版次
    @Select(ProdPackageSQL.QUERY_PROD_PACKAGE_BY_UID3)
    @Results(id = "queryProdPackageByUid3", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "fac_code", property = "facCode"),
            @Result(column = "prod_production_uid", property = "prodProductionUid"),
            @Result(column = "species_code", property = "speciesCode"),
            @Result(column = "species_name", property = "speciesName"),
            @Result(column = "species_describe", property = "speciesDescribe"),
            @Result(column = "species_approval_state", property = "speciesApprovalState"),
            @Result(column = "is_setup", property = "isSetup"),
            @Result(column = "start_time", property = "startTime"),
            @Result(column = "invalid_time", property = "invalidTime"),
            @Result(column = "version", property = "version"),
            @Result(column = "remark", property = "remark"),
            @Result(column = "c_user_uid", property = "ccUserUid"),
            @Result(column = "c_time", property = "ccTime"),
            @Result(column = "m_user_uid", property = "mmUserUid"),
            @Result(column = "m_time", property = "mmTime"),
            @Result(column = "del_flag", property = "delFlag")
    })
    ProdPackage queryProdPackageByUid3(String uid);

    //修改时查询产品套餐编号是否已经存在（不包含本身）
    @Select(ProdPackageSQL.QUERY2_PROD_PACKAGE_BY_CODE)
    @Results(id = "query2ProdPackageByCode", value = {
            @Result(column = "count", property = "count")
    })
    int query2ProdPackageByCode(@Param("speciesCode") String speciesCode, @Param("speciesCode2") String speciesCode2);

    //修改时查询产品套餐名称是否已经存在（不包含本身）
    @Select(ProdPackageSQL.QUERY2_PROD_PACKAGE_BY_NAME)
    @Results(id = "query2ProdPackageByName", value = {
            @Result(column = "count", property = "count")
    })
    int query2ProdPackageByName(@Param("speciesName") String speciesName, @Param("speciesName2") String speciesName2);

    //修改产品套餐信息表
    @Update(ProdPackageSQL.UPDATE_PROD_PACKAGE)
    int updateProdPackage(ProdPackageUpdateDTO prodPackageUpdateDTO);

    //设置产品套餐信息表
    @Update(ProdPackageSQL.SET_TIME_PROD_PACKAGE)
    int setTimeProdPackage(ProdPackageUpdateDTO prodPackageUpdateDTO);

    //根据主键查询产品套餐唯一数据
    @Select(ProdPackageSQL.QUERY_PROD_PACKAGE_BY_UID)
    @Results(id = "queryProdPackageByUid", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "prod_name", property = "prodName"),
            @Result(column = "prod_production_uid", property = "prodProductionUid"),
            @Result(column = "species_code", property = "speciesCode"),
            @Result(column = "species_name", property = "speciesName"),
            @Result(column = "species_describe", property = "speciesDescribe"),
            @Result(column = "species_approval_state", property = "speciesApprovalState"),
            @Result(column = "is_setup", property = "isSetup"),
            @Result(column = "start_time", property = "startTime"),
            @Result(column = "invalid_time", property = "invalidTime"),
            @Result(column = "version", property = "version"),
            @Result(column = "remark", property = "remark"),
            @Result(column = "c_user_uid", property = "ccUserUid"),
            @Result(column = "c_time", property = "ccTime")
    })
    ProdPackageQueryVO queryProdPackageByUid(String uid);

    //删除产品套餐信息表
    @Update(ProdPackageSQL.DELETE_PROD_PACKAGE)
    int deleteProdPackage(ProdPackageDeleteDTO prodPackageDeleteDTO);

    //提交产品套餐信息表
    @Update(ProdPackageSQL.SUBMIT_PROD_PACKAGE)
    int submitProdPackage(ProdPackageUpdateDTO prodPackageUpdateDTO);

    //审批通过产品套餐信息表
    @Update(ProdPackageSQL.PASS_PROD_PACKAGE)
    int passProdPackage(ProdPackageUpdateDTO prodPackageUpdateDTO);

    //审批驳回产品套餐信息表
    @Update(ProdPackageSQL.REJECT_PROD_PACKAGE)
    int rejectProdPackage(ProdPackageService_ prodPackageService_);

    //根据条件查询产品套餐数据条数
    @Select({ProdPackageSQL.QUERY_PROD_PACKAGE_ALL_COUNT})
    @Results(id = "queryProdPackageAllCount", value = {
            @Result(column = "count", property = "count")
    })
    int queryProdPackageAllCount(@Param("typeName") String typeName, @Param("prodName") String prodName, @Param("speciesName") String speciesName, @Param("speciesApprovalState") String speciesApprovalState);

    //根据条件查询产品套餐所有数据
    @Select({ProdPackageSQL.QUERY_PROD_PACKAGE_ALL})
    @Results(id = "queryProdPackageAll", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "type_name", property = "typeName"),
            @Result(column = "prod_name", property = "prodName"),
            @Result(column = "species_code", property = "speciesCode"),
            @Result(column = "species_name", property = "speciesName"),
            @Result(column = "species_describe", property = "speciesDescribe"),
            @Result(column = "species_approval_state", property = "speciesApprovalState"),
            @Result(column = "is_setup", property = "isSetup"),
            @Result(column = "start_time", property = "startTime"),
            @Result(column = "invalid_time", property = "invalidTime"),
            @Result(column = "version", property = "version"),
            @Result(column = "remark", property = "remark"),
            @Result(column = "c_user_uid", property = "ccUserUid"),
            @Result(column = "c_time", property = "ccTime")
    })
    List<ProdPackageQueryVO> queryProdPackageAll(@Param("typeName") String typeName, @Param("prodName") String prodName, @Param("speciesName") String speciesName, @Param("speciesApprovalState") String speciesApprovalState, @Param("page") int page, @Param("limit") int limit);

    //根据条件查询产品套餐设置数据条数
    @Select({ProdPackageSQL.QUERY_PROD_PACKAGE_SET_TIME_ALL_COUNT})
    @Results(id = "queryProdPackageSetTimeAllCount", value = {
            @Result(column = "count", property = "count")
    })
    int queryProdPackageSetTimeAllCount(@Param("typeName") String typeName, @Param("prodName") String prodName, @Param("speciesName") String speciesName);

    //根据条件查询产品套餐设置所有数据
    @Select({ProdPackageSQL.QUERY_PROD_PACKAGE_SET_TIME_ALL})
    @Results(id = "queryProdPackageSetTimeAll", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "type_name", property = "typeName"),
            @Result(column = "prod_name", property = "prodName"),
            @Result(column = "species_code", property = "speciesCode"),
            @Result(column = "species_name", property = "speciesName"),
            @Result(column = "species_describe", property = "speciesDescribe"),
            @Result(column = "species_approval_state", property = "speciesApprovalState"),
            @Result(column = "is_setup", property = "isSetup"),
            @Result(column = "start_time", property = "startTime"),
            @Result(column = "invalid_time", property = "invalidTime"),
            @Result(column = "version", property = "version"),
            @Result(column = "remark", property = "remark"),
            @Result(column = "c_user_uid", property = "ccUserUid"),
            @Result(column = "c_time", property = "ccTime")
    })
    List<ProdPackageQueryVO> queryProdPackageSetTimeAll(@Param("typeName") String typeName, @Param("prodName") String prodName, @Param("speciesName") String speciesName, @Param("page") int page, @Param("limit") int limit);

    //根据条件查询产品套餐审批数据条数
    @Select({ProdPackageSQL.QUERY_PROD_PACKAGE_APPROVE_ALL_COUNT})
    @Results(id = "queryProdPackageApproveAllCount", value = {
            @Result(column = "count", property = "count")
    })
    int queryProdPackageApproveAllCount(@Param("typeName") String typeName, @Param("prodName") String prodName, @Param("speciesName") String speciesName);

    //根据条件查询产品套餐审批所有数据
    @Select({ProdPackageSQL.QUERY_PROD_PACKAGE_APPROVE_ALL})
    @Results(id = "queryProdPackageApproveAll", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "type_name", property = "typeName"),
            @Result(column = "prod_name", property = "prodName"),
            @Result(column = "species_code", property = "speciesCode"),
            @Result(column = "species_name", property = "speciesName"),
            @Result(column = "species_describe", property = "speciesDescribe"),
            @Result(column = "species_approval_state", property = "speciesApprovalState"),
            @Result(column = "is_setup", property = "isSetup"),
            @Result(column = "start_time", property = "startTime"),
            @Result(column = "invalid_time", property = "invalidTime"),
            @Result(column = "version", property = "version"),
            @Result(column = "remark", property = "remark"),
            @Result(column = "c_user_uid", property = "ccUserUid"),
            @Result(column = "c_time", property = "ccTime")
    })
    List<ProdPackageQueryVO> queryProdPackageApproveAll(@Param("typeName") String typeName, @Param("prodName") String prodName, @Param("speciesName") String speciesName, @Param("page") int page, @Param("limit") int limit);

    //根据条件查询产品套餐名称
    @Select({ProdPackageSQL.QUERY_PROD_PACKAGE_NAME})
    @Results(id = "queryProdPackageName", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "species_name", property = "speciesName")
    })
    List<ProdPackageQueryVO> queryProdPackageName(String prodName);

    //根据条件查询产品套餐服务项及参数
    @Select({ProdPackageSQL.QUERY_PROD_PACKAGE_NAME_VALUE})
    @Results(id = "queryProdPackageServiceNameValue", value = {
            @Result(column = "service_option_name", property = "serviceOptionName"),
            @Result(column = "value", property = "value")
    })
    List<ProdPackageQueryVO> queryProdPackageServiceNameValue(String speciesName);

}
